package com.uyaer.duobao163.vo;

import android.annotation.SuppressLint;
import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

@SuppressLint("UseSparseArrays")
public class AwardItemDescManager {
	private static AwardItemDescManager instance = new AwardItemDescManager();
	
	
	public static AwardItemDescManager getInstance() {
		return instance;
	}
	
	private HashMap<Integer, ItemDesc> map = new HashMap<Integer, AwardItemDescManager.ItemDesc>();
	
	public void setData(JSONArray jarr){
		int len = jarr.length();
		for (int i = 0; i < len; i++) {
			try {
				JSONObject jobj = jarr.getJSONObject(i);
				ItemDesc item = new ItemDesc();
				item.setData(jobj);
				map.put(item.id, item);
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	}
	
	public ItemDesc getItemDescById(int id){
		ItemDesc item = map.get(id);
		return item;
	}


	public class ItemDesc{
		public int id;
		public int overlap;
		public String desc;
		public String name;
		
		public void setData(JSONObject jobj){
			try {
				this.id = jobj.getInt("id");
				this.overlap = jobj.getInt("overlap");
				this.desc = jobj.getString("desc");
				this.name = jobj.getString("name");
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	}
}
